nums = [0, 0, 1, 1, 1, 2, 2, 3, 3, 4]

i = 1

for j in range(len(nums)):
    if nums[j] != nums[i - 1]:
        nums[i] = nums[j]
        i = i + 1

print(i)
print(nums[0:i])
